package configuration.dataObjects
{
	import mx.collections.ArrayCollection;
	[Bindable]
	public class CompanyDO
	{
		public var COMPANY:String = "";
		public var NAME:String = "";
		public var ACTIVE:String = "Y";
		public var USER_STAMP:String = "";
		public var DATE_TIME_STAMP:String = "";
		public var INTERNAL_NUM:int = 0;

		public function CompanyDO()
		{
		}
		
		public function Init(xmlObj:XML):void{
			if(null == xmlObj)
				return;
			else{
				for each (var itemProp:XML in xmlObj.children()) {
					//Use XML node name to reference matching property in value object				
					this[itemProp.name()] = itemProp;
				}
			}			
		}
		
		public function ToXML():XML{
			var xmlObj:XML = 
			<COMPANY>
				<COMPANY>{COMPANY}</COMPANY>
				<NAME>{NAME}</NAME>
				<ACTIVE>{ACTIVE}</ACTIVE>
				<USER_STAMP>{USER_STAMP}</USER_STAMP>
				<DATE_TIME_STAMP>{DATE_TIME_STAMP}</DATE_TIME_STAMP>
				<INTERNAL_NUM>{INTERNAL_NUM}</INTERNAL_NUM>
			</COMPANY>;
			return xmlObj;
		}

		public static function getItems(list:XMLList):ArrayCollection
		{
			var ac:ArrayCollection = new ArrayCollection();
			for each(var xml:XML in list)
			{
				var wavDO:CompanyDO = new CompanyDO();
				wavDO.Init(xml);
				ac.addItem(wavDO);
			}
			return ac;
		}
	}
}